<template>
    <view >
        <u-checkbox-group 
         @change="checkboxGroupChange"
         v-if="formObj.value == ''|| formObj.value.length == 0">
				<u-checkbox v-model="item.checked" v-for="(item, index) in checkboxList" :key="index" :name="item.name"
				shape="circle"
				:disabled="disabled"
                >
					{{ item.name }}
				</u-checkbox>
			</u-checkbox-group>
            <text v-else>
                {{formObj.value}}
            </text>
    </view>
</template>
<script>
export default {

    props: {
        formObj: {
            type: Object,
            
        }
    },

    data () {
        return {

            checkboxObj: {},
                checkboxList: [

                ],
                disabled: false
        }
    },

    mounted() {
        this.checkboxObj = this.formObj

        var item = this.checkboxObj.items
        // var currentValue = []
        // if(this.formObj.value){
        //      currentValue = this.formObj.value.split(',')
        //      this.disabled = true
        // }

        item.map((item,index)=>this.checkboxList.push({
            value: item.label_value,
            name: item.label_name,
            checked: false,
            disabled: false
        }))

       

    },
    methods: {

            checkboxGroupChange(e) {
                console.log(e.join())
           var obj = {
                key: this.checkboxObj.name,
                value: e.join()
            }
            this.$emit('childFn',obj)

        }
    }


    
}
</script>

<style lang="less" scoped>

</style>